package com.kaifamiao.www.IP.do0928;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class BroadSend {
    public static void main(String[] args) throws Exception{

        //创建发送端Scoket对象
        DatagramSocket socket = new DatagramSocket();
        InetAddress address = InetAddress.getByName("255.255.255.255");
        String str = "广播，广播";
        int port = 8888;
        //创建数据包
        DatagramPacket packet = new DatagramPacket(str.getBytes(),str.getBytes().length,address,port);
        socket.send(packet);
        socket.close();
        System.out.println("发送成功");
    }
}
